package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ClassManagementMapper;
import com.ruoyi.system.domain.ClassManagement;
import com.ruoyi.system.service.IClassManagementService;
import com.ruoyi.common.core.text.Convert;

import javax.annotation.Resource;

/**
 * 班级管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-11-09
 */
@Service
public class ClassManagementServiceImpl implements IClassManagementService 
{
    @Resource
    private ClassManagementMapper classManagementMapper;

    /**
     * 查询班级管理
     * 
     * @param classMajorkey 班级管理主键
     * @return 班级管理
     */
    @Override
    public ClassManagement selectClassManagementByClassMajorkey(String classMajorkey)
    {
        return classManagementMapper.selectClassManagementByClassMajorkey(classMajorkey);
    }

    /**
     * 查询班级管理列表
     * 
     * @param classManagement 班级管理
     * @return 班级管理
     */
    @Override
    public List<ClassManagement> selectClassManagementList(ClassManagement classManagement)
    {
        return classManagementMapper.selectClassManagementList(classManagement);
    }

    /**
     * 新增班级管理
     * 
     * @param classManagement 班级管理
     * @return 结果
     */
    @Override
    public int insertClassManagement(ClassManagement classManagement)
    {
        if (classManagement.getClassMajorkey() == null||"".equals(classManagement.getClassMajorkey())){
            String uuid = UUID.randomUUID().toString();
            String s="PHID"+ DateUtils.dateTime()+uuid.substring(uuid.length()-5,uuid.length()-1);
            classManagement.setClassMajorkey(s);
        }
        return classManagementMapper.insertClassManagement(classManagement);
    }

    /**
     * 修改班级管理
     * 
     * @param classManagement 班级管理
     * @return 结果
     */
    @Override
    public int updateClassManagement(ClassManagement classManagement)
    {
        return classManagementMapper.updateClassManagement(classManagement);
    }

    /**
     * 批量删除班级管理
     * 
     * @param classMajorkeys 需要删除的班级管理主键
     * @return 结果
     */
    @Override
    public int deleteClassManagementByClassMajorkeys(String classMajorkeys)
    {
        return classManagementMapper.deleteClassManagementByClassMajorkeys(Convert.toStrArray(classMajorkeys));
    }

    /**
     * 删除班级管理信息
     * 
     * @param classMajorkey 班级管理主键
     * @return 结果
     */
    @Override
    public int deleteClassManagementByClassMajorkey(String classMajorkey)
    {
        return classManagementMapper.deleteClassManagementByClassMajorkey(classMajorkey);
    }

    @Override
    public List<String> classs() {
        return classManagementMapper.classs();
    }
}
